package equive.bdd;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Postgres {
	public static void main(String args[]){
		System.out.println("Hola");
		
		Connection con = null;
        Statement st = null;
        ResultSet rs = null;
        
		String url = "jdbc:postgresql://127.0.0.1/prueba";
        String user = "postgres";
        String password = "postgres";
        try {
            con = DriverManager.getConnection(url, user, password);
            st =  con.createStatement();
            rs = st.executeQuery("SELECT version()");

            if (rs.next()) {
                System.out.println(rs.getString(1));
            }

        } catch (SQLException ex) {
        
        	System.out.println(ex);

        } finally {
            try {
                if (rs != null) {
                    rs.close();
                }
                if (st != null) {
                    st.close();
                }
                if (con != null) {
                    con.close();
                }

            } catch (SQLException ex) {
             
            	System.out.println(ex);
            }
        }
    }
}
